package com.parktech.sun.domain.model;

import javax.persistence.*;
import java.io.Serializable;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by IntelliJ IDEA.
 * User: Think
 * Date: 2010-9-25
 * Time: 2:03:14
 */
@MappedSuperclass
public abstract class BaseEntity implements Serializable {

    protected DateFormat df = new SimpleDateFormat("yyyy-MM-dd");

    protected Long id = new Long("-1");

    private Date createTime;

    private Date modifyTime;

    private String creator;

    private String modifier;

    public BaseEntity() {
    }

    public BaseEntity(Long id) {
        this.id = id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getModifyTime() {
        return modifyTime;
    }

    public void setModifyTime(Date modifyTime) {
        this.modifyTime = modifyTime;
    }
    
    @Column(length = 100)
    public String getCreator() {
        return creator;
    }

    public void setCreator(String creator) {
        this.creator = creator;
    }

    @Column(length = 100)
    public String getModifier() {
        return modifier;
    }

    public void setModifier(String modifier) {
        this.modifier = modifier;
    }

    @Transient
    public boolean isNew() {
        return (id == -1L);
    }
    @Transient
    protected abstract Long getId();
}
